package com.ham.mud.classes;

import com.ham.mud.characters.Experience;
import com.ham.mud.characters.Stats;
import com.ham.mud.commands.skills.FleeSkill;
import com.ham.mud.commands.skills.Skill;
import com.ham.mud.commands.spells.Spell;
import com.ham.mud.commands.spells.damage.CauseCriticalSpell;
import com.ham.mud.commands.spells.damage.CauseLightSpell;
import com.ham.mud.commands.spells.damage.CauseSeriousSpell;
import com.ham.mud.commands.spells.damage.HarmSpell;
import com.ham.mud.commands.spells.heal.*;
import com.ham.mud.commands.spells.utility.ContinualLightSpell;

import java.util.*;

/**
 * Created by hlucas on Jun 28, 2011 at 11:43:43 AM
 */
public class Cleric extends MudClass {
    private static List<Integer> levels = new ArrayList<Integer>();
    private static Map<Integer, List<Skill>> skills = new HashMap<Integer, List<Skill>>();
    private static Map<Integer, List<Spell>> spells = new HashMap<Integer, List<Spell>>();

    static {
        skills.put(1, Arrays.asList(    (Skill) new FleeSkill()));

        spells.put(1, Arrays.asList(            new ContinualLightSpell(),
                                                new CauseLightSpell()));

        spells.put(2, Arrays.asList(    (Spell) new CureLightSpell()));

        spells.put(5, Arrays.asList(    (Spell) new CauseSeriousSpell()));

        spells.put(6, Arrays.asList(            new CureSeriousSpell(),
                                                new RefreshSpell()));

        spells.put(9, Arrays.asList(    (Spell) new CauseCriticalSpell()));

        spells.put(10, Arrays.asList(   (Spell) new CureCriticalSpell()));

        spells.put(19, Arrays.asList(   (Spell) new HarmSpell()));

        spells.put(20, Arrays.asList(   (Spell) new HealSpell()));

        int exp = 14;
        levels.add(0);
        for(int i = 1; i < 50; i++) {
            levels.add(levels.get(i - 1) + i * exp);
        }
    }

    @Override
    public String getName() {
        return "Cleric";
    }

    @Override
    public Map<Integer, List<Skill>> getSkills() {
        return skills;
    }

    @Override
    public Map<Integer, List<Spell>> getSpells() {
        return spells;
    }

    @Override
    public Stats getBaseStats() {
        return new Stats(-1, 2, -1, 1, 1, 1);
    }

    @Override
    public Integer getStartingHealth() {
        return 50;
    }

    @Override
    public Integer getHealthPerLevel() {
        return 10;
    }

    @Override
    public Integer getStartingMana() {
        return 50;
    }

    @Override
    public Integer getManaPerLevel() {
        return 10;
    }

    @Override
    public Integer getMovePerLevel() {
        return 5;
    }

    @Override
    public int getLevel(Experience experience) {
        int count = experience.getCount();
        for(int i = 0; i < levels.size(); i++) {
            Integer levelAt = levels.get(i);
            if(levelAt > count) {
                return i;
            }
        }
        return 1;
    }

    @Override
    public int getToNextLevel(Experience experience) {
        int currentLevel = getLevel(experience);
        int nextLevel = levels.get(currentLevel);
        return nextLevel - experience.getCount();
    }
}
